import React ,{ useEffect, useState } from 'react'
import {
  BrowserRouter as Router,
  Routes,
  Route,
  useLocation
} from 'react-router-dom'

import { ConfigProvider } from 'zarm'
// import zhCN from 'zarm/lib/config-provider/locale/zh_CN'
// import 'zarm/dist/zarm.css'
import './style/fix.less'
import routes from '../src/router'
import NavBar from './components/NavBar'

function App() {
  const location = useLocation()
  const { pathname } = location
  const needNav = ['/', '/data','/user']
  const [showNav, setShowNav] = useState(true)

  useEffect(() => {
    setShowNav(needNav.includes(pathname))
  },[pathname])

  return (
    <>
      <ConfigProvider primaryColor={'#007fff'}>
        <Routes>
        {routes.map(route => <Route exact key={route.path} path={route.path} element={<route.component/>}/>)}
        </Routes>
      </ConfigProvider>
      <NavBar showNav={showNav}/>
   </>
  )
}

export default App
